class CommonAddressesController < ApplicationController
  def index
    @common_addresses = CommonAddress.all
  end
  
  def show
    @common_address = CommonAddress.find(params[:id])
    @location = GeoKit::Geocoders::MultiGeocoder.geocode(@common_address.address)
  end
  
  def new
    @common_address = CommonAddress.new
  end
  
  def create
    @common_address = CommonAddress.new(params[:common_address])
    if @common_address.save
      flash[:notice] = "Successfully created common address."
      redirect_to @common_address
    else
      render :action => 'new'
    end
  end
  
  def edit
    @common_address = CommonAddress.find(params[:id])
  end
  
  def update
    @common_address = CommonAddress.find(params[:id])
    if @common_address.update_attributes(params[:common_address])
      flash[:notice] = "Successfully updated common address."
      redirect_to @common_address
    else
      render :action => 'edit'
    end
  end
  
  def destroy
    @common_address = CommonAddress.find(params[:id])
    @common_address.destroy
    flash[:notice] = "Successfully destroyed common address."
    redirect_to common_addresses_url
  end
end
